package ru.nsu.ccfit.kalah.view.field;


import android.graphics.*;

public class Ball {
    private PointF position;

    private int radius;
    private int color;
    Paint paint = new Paint();
    Paint paintStroke = new Paint();
    public Ball(PointF position, int radius, int color) {
        this.position = position;
        this.radius = radius;
        this.color = color;
        paint.setAntiAlias(true);
        paint.setColor(color);
        paint.setStyle(Paint.Style.FILL_AND_STROKE);


        paintStroke.setAntiAlias(true);
        paintStroke.setStyle(Paint.Style.STROKE);
        paintStroke.setColor(darker2());

        paintStroke.setStrokeWidth(3);

    }

    private int darker2() {
        float[] hsv = new float[3];

        Color.colorToHSV(color, hsv);
        hsv[2] *= 0.5f; // value component
        return Color.HSVToColor(hsv);
    }
    private int darker() {
        float[] hsv = new float[3];

        Color.colorToHSV(color, hsv);
        hsv[2] *= 0.7f; // value component
        return Color.HSVToColor(hsv);
    }
    public void draw(Canvas canvas) {
        RadialGradient gradient = new RadialGradient(position.x, position.y, radius, color, darker(), Shader.TileMode.CLAMP) ;

        paint.setShader(gradient);
        canvas.drawCircle(position.x, position.y, radius, paint);

        canvas.drawCircle(position.x, position.y, radius, paintStroke);
    }

    public PointF getPosition() {
        return position;
    }
}
